package calao.storage.bdb;

import com.sleepycat.bind.tuple.TupleInput;

import calao.storage.DataBinding;
import calao.storage.DataReader;
import calao.storage.UnknownBindingException;

public class TupleDataReader 
extends DataReader 
{
	
	final TupleInput input;
	
	boolean ready = true;
	
	TupleDataReader(TupleInput source, int size)
	{
		input = new TupleInput(source.getBufferBytes(), source.getBufferOffset(), size);
	}

	@Override
	public double readDouble() 
	{
		return input.readDouble();
	}

	@Override
	public int readInt() 
	{
		return input.readPackedInt();
	}

	@Override
	public long readLong() 
	{
		return input.readLong();
	}

	@Override
	public String readString() 
	{
		return input.readString();
	}
	
	@Override
	public DataBinding readBindingName()
	throws UnknownBindingException
	{
		return BdbStorage.envRegistry.getDataBinding(input.readPackedInt());
	}

	@Override
	public boolean readBoolean() 
	{
		return input.readBoolean();
	}

}
